<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        电梯日常巡查
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../css/main.css" media="all">
    <script type="text/javascript" src="../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../css/bootstrap.css">
    <link rel="stylesheet" href="../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
    </style>
</head>

<body>
<div>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>项目信息</cite></a>
            <a><cite>电梯日常巡查</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
    </div>

    <form style="padding-left: 2%" class="layui-form x-center">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label">使用单位</label>
                <div class="layui-input-inline">
                    <select name="company">
                        <option value="">---</option>
                    </select>
                </div>
                <label class="layui-form-label">项目名称</label>
                <div class="layui-input-inline">
                    <input  autocomplete="off"  type="text" class="layui-input" name="name" placeholder="项目名称">
                </div>
                <!--<label class="layui-form-label">电梯位置</label>-->
                <!--<div class="layui-input-inline">-->
                <!--<input  autocomplete="off"  type="text" class="layui-input" name="adderss" placeholder="电梯位置">-->
                <!--</div>-->
                <!--<label class="layui-form-label">巡查人员</label>-->
                <!--<div class="layui-input-inline">-->
                <!--<input  autocomplete="off"  type="text" class="layui-input" name="xcry" placeholder="巡查人员">-->
                <!--</div>-->

                <!--<label class="layui-form-label">巡查问题</label>-->
                <!--<div class="layui-input-inline">-->
                <!--<select name="interest" lay-filter="aihao">-->
                <!--<option value=""></option>-->
                <!--<option value="0">有</option>-->
                <!--<option value="1" selected="">无</option>-->
                <!--</select>-->
                <!--</div>-->
                <div class="layui-input-inline layui-show-xs-block">
                    <button class="layui-btn" type="button" lay-filter="sreach" data-type="reload"
                            onclick="reload()">
                        <i class="layui-icon">&#xe615;</i></button>
                </div>

            </div>
        </div>
    </form>


    <div class="layui-card-body">

        <table class="layui-table" id="test" lay-filter="test">
        </table>
    </div>
    <br><br><br><br><br><br>
</div>
</body>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="view">详情</a>


</script>


<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/myAjax.js"></script>
<script type="text/javascript" src="../../js/pub.js"></script>
<script type="text/javascript" src="../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script>
    //配置插件目录
    layui.config({
        base: '../../js/'
        , version: '1.0'
    });
</script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>


<script>

    layui.use(['laydate', 'form'],
        function () {
            var laydate = layui.laydate;
            let form = layui.form;
            let request2 = {
                url: '/maintenance/company/findAll',
                data: {
                    userId: $userId,
                },
                method: "get",
            };
            sendRequest(request2, (res) => {
                let d = res.data;
                $.each(d, function (index, item) {
                    let opt = $("<option value=" + item.id + ">" + item.name + "</option>");
                    $("select[name='company']").append(opt);
                });
                form.render('select');
            });

        });

    layui.use('table', function () {
        table = layui.table;
        //方法级渲染
        var t1 = table.render({
            elem: '#test',
            url: $baseUrl + '/maintenance/inspection/list',
            where: {
                userId: $userId,
            },
            headers: {
                token: $token
            }
            , toolbar: '#toolbarDemo',
            cols: [
                [
                    {
                        title: '使用单位',
                        fixed: 'left',
                        templet: function (item) {
                            return item.company.name
                        },
                        width: '15%'
                    },

                    {
                        title: '项目名称',
                        templet: function (item) {
                            return item.project.name
                        },
                        width: '15%'
                    },
                    {
                        title: '电梯位置',
                        templet: function (item) {
                            return item.elevator.address
                        },
                        width: '15%'
                    },
                    {
                        title: '巡查人员',
                        templet: function (item) {
                            return item.inspectionperson
                        },
                        width: '15%'
                    },
                    {
                        title: '位置信息',
                        templet: function (item) {
                            return item.addressinfo
                        },
                        width: '15%'
                    },
                    {
                        title: '有无问题',
                        templet: function (item) {
                            if (item.isproblem === 0) {
                                return '无'
                            } else {
                                return '有'
                            }
                        },
                        width: '15%'
                    },
                    {
                        title: '备注信息',
                        templet: function (item) {
                            return item.remark
                        },
                        width: '15%'

                    },
                    {
                        field: 'billingDate',
                        title: '巡查时间',
                        templet: function (item) {
                            return item.inspectiontime
                        },
                        width: '15%'
                    },
                    {
                        field: 'status',
                        title: '操作',
                        templet: '#barDemo',
                        fixed: 'right',
                        width: '8%'
                    }]
            ],
            request: {
                pageName: 'pageNum', //页码的参数名称，默认：page
                limitName: 'pageSize',
            },
            response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                ,
                statusCode: 0 //规定成功的状态码，默认：0
                ,
                msgName: 'msg' //规定状态信息的字段名称，默认：msg
                ,
                countName: 'total' //规定数据总数的字段名称，默认：count
                ,
                dataName: 'data', //规定数据列表的字段名称，默认：data
            },
            id: 'test',
            page: true,
            height: 'auto',
            even: true,
            done: function (res, curr, count) {
                //是否有权限或权限是否失效
                // authorizeState();
            }
        });

        //监听工具条
        table.on('tool(test)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            let data = obj.data; //获得当前行数据
            let layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            if (layEvent === 'view') { //详情
                admin_add('电梯巡查详情', 'elevator_routine_inspection_details.html?recordId=' + data.id)
            }
        });

    });

    function reload(value) {
        table.reload('test', {
            where: {
                inspectionperson: $("input[name=name]").val(),
                companyId: $("select[name=company]").val(),
            }
        });
    }

    function admin_add(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }



</script>

</html>
